#ifndef X_C_H
#define X_C_H

#include "common.h"

template <AllegroVersion version>
struct x0C
{
    uint16_t t;
    uint8_t subtype;
    uint8_t layer;
    uint32_t k;
    uint32_t next;
    union
    {
        uint32_t un[11];
        struct
        {
            uint32_t un1[2]; // Typically (always?) null
            uint32_t kind;
            uint32_t un5;
            int32_t coords[4];
            uint32_t un6[3];
        };
    };
    
    uint32_t TAIL;
    operator x0C<A_174>() const;
    static constexpr AllegroVersion versions[1] = {A_172};
};

#if __cplusplus >= 202002L
template <AllegroVersion version> requires(version >= A_172)
struct x0C<version>
{
    uint16_t t;
    uint8_t subtype;
    uint8_t layer;
    uint32_t k;
    uint32_t next;
    uint32_t un2;
    uint32_t un3;
    union
    {
        uint32_t un[11];
        struct
        {
            uint32_t un1[2]; // Typically (always?) null
            uint32_t kind;
            uint32_t un5;
            int32_t coords[4];
            uint32_t un6[3];
        };
    };
    COND_FIELD(version >= A_174, uint32_t, un4);

    uint32_t TAIL;
    operator x0C<A_174>() const;
    static constexpr AllegroVersion versions[1] = {A_172};
};
#else
template <> struct x0C<A_172>
{
    uint16_t t;
    uint8_t subtype;
    uint8_t layer;
    uint32_t k;
    uint32_t next;
    uint32_t un2;
    uint32_t un3;
    union
    {
        uint32_t un[11];
        struct
        {
            uint32_t un1[2]; // Typically (always?) null
            uint32_t kind;
            uint32_t un5;
            int32_t coords[4];
            uint32_t un6[3];
        };
    };

    uint32_t TAIL;
    operator x0C<A_174>() const;
    static constexpr AllegroVersion versions[1] = {A_172};
};

template <> struct x0C<A_174>
{
    uint16_t t;
    uint8_t subtype;
    uint8_t layer;
    uint32_t k;
    uint32_t next;
    uint32_t un2;
    uint32_t un3;
    union
    {
        uint32_t un[11];
        struct
        {
            uint32_t un1[2]; // Typically (always?) null
            uint32_t kind;
            uint32_t un5;
            int32_t coords[4];
            uint32_t un6[3];
        };
    };
    uint32_t un4;

    uint32_t TAIL;
    operator x0C<A_174>() const;
    static constexpr AllegroVersion versions[1] = {A_172};
};
#endif

#endif // X_C_H
